package com.medicalproject.controller;


import com.medical.pojo.CleaningWorkorder;
import com.medical.vo.Rmed;
import com.medicalproject.service.CleaningWorkorderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("Workorder")
public class CleaningWorkorderController {
    @Resource
    private CleaningWorkorderService cleaningWorkorderService;

    // 显示所有保洁工单列表
    @RequestMapping("list")
    public Rmed list(){
        return Rmed.suceessData(cleaningWorkorderService.list());
    }

    // 根据时间筛选清洁工单列表
    @RequestMapping("listtime")
    public Rmed listtime(Integer times){
        return Rmed.suceessData(cleaningWorkorderService.listtime(times));
    }

    @RequestMapping("listtimes")
    public Rmed listtimes(Integer times,String worker){
        return Rmed.suceessData(cleaningWorkorderService.listtimes(times,worker));
    }

    @RequestMapping("listtimess")
    public Rmed listtimess(Integer times,String name){
        return Rmed.suceessData(cleaningWorkorderService.listtimess(times,name));
    }
    // 根据优先级对保洁工单排序
    @RequestMapping("listyxj")
    public Rmed listyxj(Integer yid){
        return Rmed.suceessData(cleaningWorkorderService.listyxj(yid));
    }
    @RequestMapping("listyxjs")
    public Rmed listyxjs(Integer yid,String worker){
        return Rmed.suceessData(cleaningWorkorderService.listyxjs(yid,worker));
    }

    @RequestMapping("listyxjss")
    public Rmed listyxjss(Integer yid,String name){
        return Rmed.suceessData(cleaningWorkorderService.listyxjss(yid,name));
    }

    // 根据工单类型筛选清洁工单列表
    @RequestMapping("listgdlx")
    public Rmed listgdlx(Integer type){
        return Rmed.suceessData(cleaningWorkorderService.listgdlx(type));
    }

    @RequestMapping("listgdlxs")
    public Rmed listgdlxs(Integer type,String worker){
        return Rmed.suceessData(cleaningWorkorderService.listgdlxs(type,worker));
    }

    @RequestMapping("listgdlxss")
    public Rmed listgdlxss(Integer type,String name){
        return Rmed.suceessData(cleaningWorkorderService.listgdlxss(type,name));
    }


    /**
     * 根据ID查找记录
     *
     * @param id 要查找的记录的ID
     * @return 返回查找结果的Rmed对象
     */
    @RequestMapping("findById")
    public Rmed findById(Integer id){
        return Rmed.suceessData(cleaningWorkorderService.findById(id));
    }

    /**
     * 添加新的清洁工单
     *
     * @param cleaningWorkorder 要添加的清洁工单对象
     * @return 返回添加结果的Rmed对象
     */
    @RequestMapping("add")
    public Rmed add(@RequestBody CleaningWorkorder cleaningWorkorder){
        return Rmed.suceessData(cleaningWorkorderService.add(cleaningWorkorder));
    }

    /**
     * 更新记录状态
     *
     * @param id 要更新的记录的ID
     * @return 返回更新结果的Rmed对象
     */
    @RequestMapping("update")
    public Rmed updata(Integer id){
        return Rmed.suceessData(cleaningWorkorderService.updata(id));
    }

    /**
     * 根据代码查找记录
     *
     * @param code 用于查找的代码
     * @return 返回查找结果的Rmed对象
     */
    @RequestMapping("findcode")
    public Rmed findcode(String code){
        return Rmed.suceessData(cleaningWorkorderService.findcode(code));
    }

    /**
     * 处理工单更新
     *
     * @param code 工单的代码
     * @return 返回处理结果的Rmed对象
     */
    @RequestMapping("handleupdate")
    public Rmed handleupdate(String code){
        return Rmed.suceessData(cleaningWorkorderService.handleupdate(code));
    }

    /**
     * 限制更新工单
     *
     * @param code 工单的代码
     * @return 返回更新结果的Rmed对象
     */
    @RequestMapping("limitupdate")
    public Rmed limitupdate(String code){
        return Rmed.suceessData(cleaningWorkorderService.limitupdate(code));
    }

    /**
     * 处理完成工单更新
     *
     * @param code 工单的代码
     * @return 返回更新结果的Rmed对象
     */
    @RequestMapping("dealupdate")
    public Rmed dealupdate(String code){
        return Rmed.suceessData(cleaningWorkorderService.dealupdate(code));
    }

    /**
     * 评价工单
     *
     * @param cleaningWorkorder 包含评价信息的工单对象
     * @return 返回评价结果的Rmed对象
     */
    @RequestMapping("evaluate")
    public Rmed evaluate(@RequestBody CleaningWorkorder cleaningWorkorder){
        return Rmed.suceessData(cleaningWorkorderService.evaluate(cleaningWorkorder));
    }

    /**
     * 将工单置于待处理状态
     *
     * @param id 要置于待处理状态的工单的ID
     * @return 返回处理结果的Rmed对象
     */
    @RequestMapping("pending")
    public Rmed pending(Integer id){
        return Rmed.suceessData(cleaningWorkorderService.pending(id));
    }

    // 处理清洁工单调度请求
    /**
     * 调度清洁工单
     *
     * @param cleaningWorkorder 待调度的清洁工单信息
     * @return 调度结果封装在Rmed对象中
     */
    @RequestMapping("dispatcher")
    public Rmed dispatcher(@RequestBody CleaningWorkorder cleaningWorkorder){
        return Rmed.suceessData(cleaningWorkorderService.dispatcher(cleaningWorkorder));
    }

    // 处理清洁工单关闭请求
    /**
     * 关闭清洁工单
     *
     * @param cleaningWorkorder 待关闭的清洁工单信息
     * @return 关闭结果封装在Rmed对象中
     */
    @RequestMapping("close")
    public Rmed close(@RequestBody CleaningWorkorder cleaningWorkorder){
        return Rmed.suceessData(cleaningWorkorderService.close(cleaningWorkorder));
    }

    // 获取清洁工单列表
    /**
     * 获取所有清洁工单列表
     *
     * @return 清洁工单列表封装在Rmed对象中
     */
    @RequestMapping("listcleaning")
    public Rmed listbj(){
        return Rmed.suceessData(cleaningWorkorderService.listcleaning ());
    }

    // 获取维修工单列表
    /**
     * 获取所有维修工单列表
     *
     * @return 维修工单列表封装在Rmed对象中
     */
    @RequestMapping("listrepair")
    public Rmed listwx(){
        return Rmed.suceessData(cleaningWorkorderService.listrepair());
    }

    // 获取清洁任务列表
    /**
     * 获取所有清洁任务列表
     *
     * @return 清洁任务列表封装在Rmed对象中
     */
    @RequestMapping("listclean")
    public Rmed listclean(){
        return Rmed.suceessData(cleaningWorkorderService.listclean());
    }

    // 根据类型获取执行状态列表
    /**
     * 根据类型获取执行状态列表
     *
     * @param type 类型标识
     * @return 执行状态列表封装在Rmed对象中
     */
    @RequestMapping("listexecutionstatus")
    public Rmed listexecutionstatus(Integer type){
        return Rmed.suceessData(cleaningWorkorderService.listexecutionstatus(type));
    }

    @RequestMapping("listexecutionstatuss")
    public Rmed listexecutionstatuss(Integer type,String worker){
        return Rmed.suceessData(cleaningWorkorderService.listexecutionstatuss(type,worker));
    }
    @RequestMapping("listexecutionstatusss")
    public Rmed listexecutionstatusss(Integer type,String name){
        return Rmed.suceessData(cleaningWorkorderService.listexecutionstatusss(type,name));
    }

    // 根据名称获取列表
    /**
     * 根据名称搜索列表
     *
     * @param name 名称关键词
     * @return 搜索结果列表封装在Rmed对象中
     */
    @RequestMapping("listname")
    public Rmed listname(String name){
        return Rmed.suceessData(cleaningWorkorderService.listname(name));
    }

    @RequestMapping("list2")
    public Rmed list2(String worker){
        return Rmed.suceessData(cleaningWorkorderService.listworker(worker));
    }

    @RequestMapping("listcleanings")
    public Rmed listcleanings(String worker){
        return Rmed.suceessData(cleaningWorkorderService.listcleanings(worker));
    }

    @RequestMapping("listrepairs")
    public Rmed listrepairs(String worker){
        return Rmed.suceessData(cleaningWorkorderService.listrepairs(worker));
    }

    @RequestMapping("listcleans")
    public Rmed listcleans(String worker){
        return Rmed.suceessData(cleaningWorkorderService.listcleans(worker));
    }

    @RequestMapping("listcleaningss")
    public Rmed listcleaningss(String name){
        return Rmed.suceessData(cleaningWorkorderService.listcleaningss(name));
    }

    @RequestMapping("listrepairss")
    public Rmed listrepairss(String name){
        return Rmed.suceessData(cleaningWorkorderService.listrepairss(name));
    }

    @RequestMapping("listcleanss")
    public Rmed listcleanss(String name){
        return Rmed.suceessData(cleaningWorkorderService.listcleanss(name));
    }



}
